package org.diysearch.helpers;

import java.util.List;

import org.diysearch.dao.interfaces.CommentDao;
import org.diysearch.interfaces.Constants;
import org.diysearch.models.Comment;
import org.diysearch.tools.BaseTool;

public abstract class CommentHelper {
	private static final CommentDao dao = (CommentDao) BaseTool.IOC_ENGINE.getBean("commentDao");
	public static List<Comment> getComments (int item, int oid) throws Exception {
		return dao.findByItemAndOid(item, oid);
	}
	public static int deleteComments (int item, int oid) throws Exception {
		Comment c = new Comment();
		c.setItem(item);
		c.setObjectId(oid);
		return dao.delete(c);
	}
	
	public static Comment getComment (int id) throws Exception {
		return dao.findById(id);
	}
	
	public static List<Comment> getCommentsForUser (int uid) throws Exception {
		return dao.findByOwner(uid);
	}
	
	public static Comment save(Comment c) throws Exception {
		return dao.save(c);
	}
	
	
}
